#!/bin/bash
QUA="quarantined"
LOG="log.txt"
UpPath="/Users/momachuanmei/微云同步盘"

function find()
{
    SUFFIXS=($1"/.*.php" $1"/*.php" $1"/.*.gif" $1"/*.gif" $1"/.*.jpg" $1"/*.jpg")

    for i in ${SUFFIXS[@]}
    do
        if [ -f $i ]
        then
            # echo "----> $i"
            INFO=`ls -l "$i"`
            DATA=`date +%F`
            echo "[$DATA] $INFO">>$LOG
            cp `$i` $QUA
            # rm -f "$i"
        fi
    done
}

function read_dir()
{
    find $1

    for file in `ls $1`
    do
        if [ -d $1"/"$file ]
        then
            read_dir $1"/"$file
        fi
    done
}

read_dir $UpPath
exit 0

GLOBAL_PID="PID"

if [ -r "$GLOBAL_PID" ]; then
    # echo "this $GLOBAL_PID"
    PID=`cat "$GLOBAL_PID"`
    echo "PID: $PID"
    # kill s -9 $PID >/dev/null 2>&1
    if [ $? -gt 0 ]; then
        echo "PID file found but no matching process was found. Stop aborted."
        exit 1
    fi
    # rm -f "$GLOBAL_PID"
    # echo "$PID"
    echo "Project Stoppd"
    exit 0
else
    echo "Unable to read PID file. Stop aborted."
    exit 1
fi